package cn.lytcom.architecture;

import android.content.Context;

import javax.inject.Singleton;

import cn.lytcom.architecture.api.AppRestQueue;
import cn.lytcom.architecture.data.DataProvider;
import cn.lytcom.architecture.data.IDataProvider;
import cn.lytcom.architecture.manager.DbManager;
import cn.lytcom.architecture.manager.SpManager;
import cn.lytcom.architecture.manager.ThreadManager;
import dagger.Module;
import dagger.Provides;

/**
 * Created by lytcom on 2017/4/23.
 */

@Module
public class AppModule {

    private Context context;

    public AppModule(Context context) {
        this.context = context.getApplicationContext();
    }

    @Provides
    @Singleton
    public Context providesContext() {
        return context;
    }

    @Provides
    @Singleton
    public SpManager providesSpManager() {
        return new SpManager(context);
    }

    @Provides
    @Singleton
    public DbManager providesDbManager() {
        return new DbManager(context);
    }

    @Provides
    @Singleton
    public AppRestQueue providesAppRestQueue() {
        return new AppRestQueue();
    }

    @Provides
    @Singleton
    public IDataProvider providesDataProvider(AppRestQueue appRestQueue, DbManager dbManager, SpManager spManager) {
        return new DataProvider(context, appRestQueue, dbManager, spManager);
    }

    @Provides
    @Singleton
    public ThreadManager providesThreadManager() {
        return new ThreadManager();
    }
}
